package org.syyo.admin.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.syyo.admin.anno.CheckPermissions;
import org.syyo.admin.anno.SysLog;
import org.syyo.admin.domain.ResultVo;
import org.syyo.admin.domain.request.NoticeReq;
import org.syyo.admin.service.NoticeService;

/**
 * @Auther: wangzhong
 * @Date: 2019/12/4 18:07
 * @Description: 通告
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService roleService;

    @SysLog("通告添加")
    @CheckPermissions("system:notice:add")
    @PostMapping("/add")
    public ResultVo addNotice(@RequestBody NoticeReq req){
        return  roleService.addNotice(req);
    }

    @SysLog("通告删除")
    @CheckPermissions("system:notice:del")
    @PostMapping("/del")
    public ResultVo delNotice(@RequestBody NoticeReq req){
        return  roleService.delNotice(req);
    }

    @SysLog("通告编辑")
    @CheckPermissions("system:notice:edit")
    @PostMapping("/edit")
    public ResultVo editNotice(@RequestBody NoticeReq req){
        return  roleService.editNotice(req);
    }

    /**
     * 通告详情
     * @param noticeId
     * @return
     */
    @CheckPermissions("system:notice:index")
    @GetMapping
    public ResultVo getNotice(@RequestParam("noticeId") Integer noticeId){
        return  roleService.getNotice(noticeId);
    }

    /**
     * 通告列表
     * @param req
     * @return
     */
    @CheckPermissions("system:notice:index")
    @GetMapping("/list")
    public ResultVo listNotice(NoticeReq req){
        return roleService.listNotice(req);
    }

}
